`timescale 1ns/1ns
`define clk_period 20

module main_tb();
	reg Clk;
	reg Rst_n;
	 
	// Uart
	wire uart_tx;
	wire uart_rx;
	 
	// Key
	reg Key0;
	reg Key1;
	reg Key2;
	 
	// LED
	wire Led0;
	wire Led1;
	wire Led2;
	wire Led3;
	
	// TFT
	wire [15:0]TFT_RGB;
	wire TFT_HS;
	wire TFT_VS;
	wire TFT_CLK;
	wire TFT_DE;
	wire TFT_PWM;

main main_instance0(
	// System
	.Clk(Clk),
	.Rst_n(Rst_n),
	
	// Uart
	.uart_tx(uart_tx),
	.uart_rx(uart_rx),
	
	// Key
	.Key0(Key0),
	.Key1(Key1),
	.Key2(Key2),
	
	// LED
	.Led0(Led0),
	.Led1(Led1),
	.Led2(Led2),
	.Led3(Led3),

	// TFT
	.TFT_RGB(TFT_RGB),
	.TFT_HS(TFT_HS),
	.TFT_VS(TFT_VS),
	.TFT_CLK(TFT_CLK),
	.TFT_DE(TFT_DE),
	.TFT_PWM(TFT_PWM)
);

	initial Clk = 1'b0;
	always #(`clk_period/2) Clk = ~Clk;
	initial begin
		Rst_n = 1;
		#(`clk_period * 2);
		Rst_n = 0;
		Key0 = 1;
		Key1 = 1;
		Key2 = 1;
		#(`clk_period * 2);
		Rst_n = 1;

		// 按键0按下到配置状态 -> send_data
		Key0 = 0;
		#(`clk_period * 15);
		Key0 = 1;
		
		// 按键1按下切换配置
		Key1 = 0;
		#(`clk_period * 15);
		Key1 = 1;
		
		// 按键0选择配置 -> bps_setting 
		Key0 = 0;
		#(`clk_period * 15);
		Key0 = 1;
		
		// 按键1切换配置
		Key1 = 0;
		#(`clk_period * 15);
		Key1 = 1;
		
		// 按键0选择配置 -> check_setting
		Key0 = 0;
		#(`clk_period * 15);
		Key0 = 1;
		
		// 按键1切换配置
		Key1 = 0;
		#(`clk_period * 15);
		Key1 = 1;
		
		// 修改配置
		#(`clk_period * 20);
		$stop;
	end
	
	
	
endmodule
